package com.example.smartcity.ui.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.smartcity.R;
import com.example.smartcity.ui.Bean.OrderHistoryBean;
import com.example.smartcity.ui.dashboard.Reservation;

import java.util.List;

public class OrderHistoryAdapter extends RecyclerView.Adapter<OrderHistoryAdapter.MyViewHolder> {

    private List<OrderHistoryBean.RowsBean> list;
    private int Resource;
    public OrderHistoryAdapter(List<OrderHistoryBean.RowsBean> list,int Resource){
        this.list = list;
        this.Resource = Resource;
    }
    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(Resource,parent,false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        holder.TVCategoryName.setText(list.get(position).getCategoryName());
        holder.TVOrderMoeny.setText(list.get(position).getMoeny());
        holder.TVOrderNo.setText(list.get(position).getOrderNo());
        holder.TVOrderPatientName.setText(list.get(position).getPatientName());
        holder.TVStartime.setText(list.get(position).getStartime());
        holder.TVTypesId.setText(list.get(position).getTypesId());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    static class MyViewHolder extends RecyclerView.ViewHolder{
        private TextView TVOrderNo;
        private TextView TVOrderMoeny;
        private TextView TVOrderPatientName;
        private TextView TVTypesId;
        private TextView TVCategoryName;
        private TextView TVStartime;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            TVOrderNo = itemView.findViewById(R.id.TV_orderNo);
            TVOrderMoeny = itemView.findViewById(R.id.TV_OrderMoeny);
            TVOrderPatientName = itemView.findViewById(R.id.TV_orderPatientName);
            TVTypesId = itemView.findViewById(R.id.TV_typesId);
            TVCategoryName = itemView.findViewById(R.id.TV_categoryName);
            TVStartime = itemView.findViewById(R.id.TV_startime);
        }
    }
}
